-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix issue with .c in folder name #126
Conversation
Should I change doom to a argument instead of a define, so it can be a runtime not a compile time patch ? |
Maybe the same for trace_verbose ? |
I don't know if C2V should have different code for different projects |
It has already :) So make doom and trace_verbose arguments instead ? |
I mean that doom specific hack should be removed and universal fix should be implemented |
But thats a bigger task than fixing a issue in the code, and if we put that on every bug fix then there will be no bug fixes :/ |
In my opinion it's better to made a solid change one time, than made a few hacky quick fixes and introduce more complexity and potential bugs into the project. In this case, what if tomorrow a new guy will come and said "my XYZ project requites specific changes to make it work", would we introduce new argument -XYZ that should be used for this specific project only? I don't think this is a good idea. I appreciate your contribution, we just need to do it in another way. Have you investigated why Doom requires that hack? |
This also just cancels that quick fix, so its not that its a new XYZ fix.
Second it cant be made an argument easily because the some of the test relies on a bash script(https://github.com/vlang/doom/blob/master/build_whole_project.sh) thats not located in this git which is strange in it self.
I guess this(c2v) and was written by someone that knows v and c very well from the beginning, and that person left it there for a reason. And that reason not being it is a easy fix or that maybe it require a change in doom. |
So i think to move forward the best is to take changes incrementally and not force this fix to change all doom related issues. |
Again, I don't think that C2V code should depends on project it translates, neither project, that works, should be changed to be able to be translated by C2V. We can't introduce copile time things like
The original C2V code was created by @medvednikov , maybe he will help to understand why this Doom specific code is here and how it can be removed. |
I changed the pull to not include the fix for doom src folder and let others fall on the same branch :/ |
Got it. I hope issue with Doom will be fixed somewhere in future. Can you please explain to me how your fix works? I nit quite understand what your changes do |
I tried to convert xml.c project to v and then i discovered that if you got .c in any folder name its also exchanged to .json so the change makes sure it only replace the last .c to . json and not all of them. |
Do you think you could implement a test for this case? |
Sure should be easy, except i need to avoid the doom hack 😁 Create anything in a ./src folder will make it change to that folder and fail because it cant find the file its trying to parse 😁 |
Not sure how this is connected to |
I will try to review it asap and will merge if everything is ok |
Test added, the same bug existed in the test runner :) |
The hack added for doom that with chdir to 'src' is only seen if you dont have absolute paths. Just for reference. |
So the hack with DOOM is needed only for CI checks? |
When it does the conversion if it finds '/src/' somewhere on the path it chdir to that location to i guess find a headerfile that in the wrong location. So if the path was relative from the start then the new relative path will be wrong. Example: v translate banana/src/test.c it will fail because it will chdir to Full test and example: $ mkdir tests/src
$ cp -a tests/test.c tests/src/
$ v run . tests/src/test.c/1.hello.c
C to V translator 0.3.1
translating tests/src/test.c/1.hello.c ... sh: line 1: tests/src/test.c/1.hello.json: No such file or directory
The file tests/src/test.c/1.hello.c could not be parsed as a C source file.
$ v run . $(pwd)/tests/src/test.c/1.hello.c
C to V translator 0.3.1
translating $HOME/c2v/tests/src/test.c/1.hello.c ... Reformatted file: $HOME/c2v/tests/src/test.c/1.hello.v
took 94 ms ; output .v file: test.c/1.hello.v
Translated 1 files in 94 ms. |
Either way this should be ready for merge $ git checkout 9a5bacb6bc6d5edf578b48890079245198c6af3a -b test-works # this pull request
Switched to a new branch 'test-works'
$ cp -a tests/test.c . # park the test from the new commit
$ git checkout 811a8b7c320d1fda9a23d4a95ed5f84ccc1f2537 -b test-fail # master and base of this pull
$ cp -a test.c/ tests/test.c # get the test from the new commit
$ v -g run tests/run_tests.vsh
building c2v...
done
Reformatted file: $HOME/dev/c2v/tests/1.hello.v
Already formatted file: $HOME/dev/c2v/tests/1.hello.v
$HOME/dev/c2v/tests/1.hello.c... OK
Reformatted file: $HOME/dev/c2v/tests/11.enum_default.v
Already formatted file: $HOME/dev/c2v/tests/11.enum_default.v
$HOME/dev/c2v/tests/11.enum_default.c... OK
Reformatted file: $HOME/dev/c2v/tests/12.if_stmt.v
Already formatted file: $HOME/dev/c2v/tests/12.if_stmt.v
$HOME/dev/c2v/tests/12.if_stmt.c... OK
Reformatted file: $HOME/dev/c2v/tests/13.switch.v
Already formatted file: $HOME/dev/c2v/tests/13.switch.v
$HOME/dev/c2v/tests/13.switch.c... OK
Reformatted file: $HOME/dev/c2v/tests/14.default.v
Already formatted file: $HOME/dev/c2v/tests/14.default.v
$HOME/dev/c2v/tests/14.default.c... OK
Reformatted file: $HOME/dev/c2v/tests/15.multi_var_decl.v
Already formatted file: $HOME/dev/c2v/tests/15.multi_var_decl.v
$HOME/dev/c2v/tests/15.multi_var_decl.c... OK
Reformatted file: $HOME/dev/c2v/tests/2.if.v
Already formatted file: $HOME/dev/c2v/tests/2.if.v
$HOME/dev/c2v/tests/2.if.c... OK
Reformatted file: $HOME/dev/c2v/tests/3.if_switch_enum.v
Already formatted file: $HOME/dev/c2v/tests/3.if_switch_enum.v
$HOME/dev/c2v/tests/3.if_switch_enum.c... OK
Reformatted file: $HOME/dev/c2v/tests/4.for.v
Already formatted file: $HOME/dev/c2v/tests/4.for.v
$HOME/dev/c2v/tests/4.for.c... OK
Reformatted file: $HOME/dev/c2v/tests/5.struct.v
Already formatted file: $HOME/dev/c2v/tests/5.struct.v
$HOME/dev/c2v/tests/5.struct.c... OK
Reformatted file: $HOME/dev/c2v/tests/6.types.v
Already formatted file: $HOME/dev/c2v/tests/6.types.v
$HOME/dev/c2v/tests/6.types.c... OK
sh: line 1: $HOME/dev/c2v/tests/src/test.json/1.hello.json: No such file or directory
The file $HOME/dev/c2v/tests/src/test.c/1.hello.c could not be parsed as a C source file.
$HOME/dev/c2v/tests/src/test.c/1.hello.c... FAIL
$ rm -fr tests/test.c # remove to not get conflict
$ git checkout test-works
Switched to branch 'test-works'
$ v -g run tests/run_tests.vsh
building c2v...
done
Reformatted file: $HOME/dev/c2v/tests/1.hello.v
Already formatted file: $HOME/dev/c2v/tests/1.hello.v
$HOME/dev/c2v/tests/1.hello.c... OK
Reformatted file: $HOME/dev/c2v/tests/11.enum_default.v
Already formatted file: $HOME/dev/c2v/tests/11.enum_default.v
$HOME/dev/c2v/tests/11.enum_default.c... OK
Reformatted file: $HOME/dev/c2v/tests/12.if_stmt.v
Already formatted file: $HOME/dev/c2v/tests/12.if_stmt.v
$HOME/dev/c2v/tests/12.if_stmt.c... OK
Reformatted file: $HOME/dev/c2v/tests/13.switch.v
Already formatted file: $HOME/dev/c2v/tests/13.switch.v
$HOME/dev/c2v/tests/13.switch.c... OK
Reformatted file: $HOME/dev/c2v/tests/14.default.v
Already formatted file: $HOME/dev/c2v/tests/14.default.v
$HOME/dev/c2v/tests/14.default.c... OK
Reformatted file: $HOME/dev/c2v/tests/15.multi_var_decl.v
Already formatted file: $HOME/dev/c2v/tests/15.multi_var_decl.v
$HOME/dev/c2v/tests/15.multi_var_decl.c... OK
Reformatted file: $HOME/dev/c2v/tests/2.if.v
Already formatted file: $HOME/dev/c2v/tests/2.if.v
$HOME/dev/c2v/tests/2.if.c... OK
Reformatted file: $HOME/dev/c2v/tests/3.if_switch_enum.v
Already formatted file: $HOME/dev/c2v/tests/3.if_switch_enum.v
$HOME/dev/c2v/tests/3.if_switch_enum.c... OK
Reformatted file: $HOME/dev/c2v/tests/4.for.v
Already formatted file: $HOME/dev/c2v/tests/4.for.v
$HOME/dev/c2v/tests/4.for.c... OK
Reformatted file: $HOME/dev/c2v/tests/5.struct.v
Already formatted file: $HOME/dev/c2v/tests/5.struct.v
$HOME/dev/c2v/tests/5.struct.c... OK
Reformatted file: $HOME/dev/c2v/tests/6.types.v
Already formatted file: $HOME/dev/c2v/tests/6.types.v
$HOME/dev/c2v/tests/6.types.c... OK
Reformatted file: $HOME/dev/c2v/tests/src/test.c/1.hello.v
Already formatted file: $HOME/dev/c2v/tests/src/test.c/1.hello.v
$HOME/dev/c2v/tests/src/test.c/1.hello.c... OK
Reformatted file: $HOME/dev/c2v/tests/test.c/1.hello.v
Already formatted file: $HOME/dev/c2v/tests/test.c/1.hello.v
$HOME/dev/c2v/tests/test.c/1.hello.c... OK
Reformatted file: $HOME/dev/c2v/tests/10.jni.v
$HOME/dev/c2v/tests/10.jni.h... OK
Reformatted file: $HOME/dev/c2v/tests/7.api_types.v
$HOME/dev/c2v/tests/7.api_types.h... OK
Reformatted file: $HOME/dev/c2v/tests/8.simple_func_header.v
$HOME/dev/c2v/tests/8.simple_func_header.h... OK
Reformatted file: $HOME/dev/c2v/tests/9.func_declaration.v
$HOME/dev/c2v/tests/9.func_declaration.h... OK |
So maybe we can make sure that path, provided in the parameters for |
Yes, thats a possible workaround but not for this pull request but for #127. |
Ok, got it. So I will merge that PR after a codereview |
Signed-off-by: Robert Marklund <[email protected]>
It wasn't so easy to create a utils file and have that imported in the test runner so it became like this instead. |
put doom hack under doom define, to use run with -d doom
related to error #124 but not a total fix this just fixes so a wrapper can be created.
May break doom tests but not when the new define is set.